package com.jeect.productweb.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;

@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    @Autowired
    private SavedRequestAwareAuthenticationSuccessHandler successHandler;
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.formLogin().loginPage("/auth/validate").loginProcessingUrl("/user/login")
                .successHandler(successHandler)
                .and()
                .authorizeRequests().antMatchers("/auth/validate","/login.html","/lib/**","/static/**","/temp/**").permitAll()

                .anyRequest().authenticated()
                .and()
                .csrf().disable();
    }
}
